package com.taotao.service;

import com.taotao.mapper.ItemMapper;
import com.taotao.pojo.Item;
import com.taotao.pojo.ItemDesc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * ${DESCRIPTION}
 *
 * @author muxiaoyu
 * @create 2017/06/27 14:54
 **/
@Service
public class ItemService {
    @Autowired
    private ItemMapper itemMapper;
    @Autowired
    private ItemDescService itemDescService;

    public List<Item> queryItemListByPage(Integer page, Integer rows) {
        return itemMapper.queryItemListByPage(page, rows);
    }

    @Transactional
    public Boolean addItem(Item item, ItemDesc itemDesc) {
        Boolean b1 = itemMapper.addItem(item);
        itemDesc.setItemId(item.getId());
        Boolean b2 = itemDescService.addItemDesc(itemDesc);
        return (b1 && b2);
    }
}
